﻿using System;
using System.Data;
using System.Data.SqlClient;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace ThienLoc
{
    public partial class DanhSachMon : System.Web.UI.Page
    {
        private static int MenuID;
        protected void Page_Load(object sender, EventArgs e)
        {
            if (Request.QueryString["mid"] != null)
            {
                MenuID = Convert.ToInt32(Request.QueryString["mid"]);
                LoadItem(MenuID);
            }
            else
            {
                LoadItem();
            }
        }

        private void LoadItem(int mID)
        {
            string sql = "select m.ID,m.Image,m.TenMonAn,m.MoTa,m.GiaTien from tblTLMonAn m where m.Menu_ID = @mID";
            List<SqlParameter> arrParams = new List<SqlParameter>();
            arrParams.Add(SqlHelper.CreateParameterObject("@mID", SqlDbType.Int, ParameterDirection.Input, mID));
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql, arrParams);
            rptItem.DataSource = dt;
            rptItem.DataBind();
        }

        private void LoadItem()
        {
            string sql = "select m.ID,m.Image,m.TenMonAn,m.MoTa,m.GiaTien from tblTLMonAn m";
            DataTable dt = SqlHelper.ExecuteDataTable(CommandType.Text, sql);
            rptItem.DataSource = dt;
            rptItem.DataBind();
        }
    }
}
